import request from '@/utils/request'
import type { ApiResponse } from '@/types/common'

// 定义任务数据类型
export interface TaskData {
  id: number
  types: number // 1: 系统任务, 2: 普通任务, 3: 自定义任务
  title: string
  link: string
  desc: string
}

// 获取任务列表
export const getTaskList = (): Promise<ApiResponse<TaskData[]>> => {
  return request({
    url: '/api/home/task/list',
    method: 'get',
  })
}

// 保存任务
export const saveTask = (data: Partial<TaskData>): Promise<ApiResponse<TaskData>> => {
  return request({
    url: '/api/home/task/save',
    method: 'post',
    data,
  })
}

// 删除任务
export const deleteTask = (data: { id: number }): Promise<ApiResponse<null>> => {
  return request({
    url: '/api/home/task/delete',
    method: 'post',
    data,
  })
}
